<!DOCTYPE html>
<html>
<body>
<script>

window.iframeLoaded = function() {
  document.location.hash = '#ready';

  var iframe = document.getElementsByTagName('iframe')[0];
  var oldScreen = iframe.contentWindow.screen;
  var oldOrient = oldScreen.orientation;

  iframe.remove();

  // The screen.orientation object will not be exposed once the
  // screen has become detached, but probe for it regardless to
  // verify that such post-detach use doesn't crash.
  oldOrient = oldScreen.orientation || oldOrient;

  oldOrient.unlock();
  document.location.hash = '#done';
}

</script>
<iframe src='detached-iframe.html'></iframe>
</body>
</html>
